/*! \file hovertext.cpp		
	This contains the implementation of the HoverText class
*/

#include "hovertext.h"

HoverText::HoverText() :
	Container( 0, true ),
	text( this )
{
	setVisible( false );
	setResizable( false );
	setDraggable( false );
	text.setGUIStyle( 6,7,8,9 );
	text.setWidth( 300 );
	setText( "DEFAULT TEXT SET IN CONSTRUCTOR" );
}

HoverText* HoverText::getInstance() {
		
	if ( instance == 0 ) {
		instance = new HoverText();
	}
	return instance;
}

void HoverText::setText( string text ) {
	cout << "Setting text to: " << text << endl;
	this->text.setText( text );
	cout << "Buffer is now: " << this->text.getText() << endl;
	layout();
}

string HoverText::getText() {
	return text.getText();
}

void HoverText::onSize( Event e ) {
	cout << "HoverText::onSize" << endl;
	layout();
}
	
void HoverText::layout() {
	cout << "Borderwidth: " << borderWidth << " w " << w << endl;
	this->text.setWidth( w - borderWidth * 2 );
	this->text.setPosition( borderWidth, borderWidth );
	h = this->text.getHeight() + borderWidth * 2;
}

bool HoverText::canHaveFocus() { 
	cout << "Testing for focus" << endl;
	
	return false;
}
